package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.wms.domain.VehicleCancellation;
import com.ruoyi.wms.dto.VehicleCancellationDto;
import com.ruoyi.wms.service.IVehicleCancellationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 机动车注销登记申请Controller
 *
 * @author libancang
 * @date 2025-09-12
 */

@Api(value = "机动车注销登记申请Controller", tags = "机动车注销登记申请Controller")
@RestController
@RequestMapping("/vehicleCancellation")
public class VehicleCancellationController extends BaseController {
    @Autowired
    private IVehicleCancellationService vehicleCancellationService;

    /**
     * 查询机动车注销登记申请列表
     */
//    @RequiresPermissions("lvlian:vehicleCancellation:list")
    @GetMapping("/list")
    public TableDataInfo list(VehicleCancellationDto vehicleCancellation) {
        startPage();
        List<VehicleCancellation> list = vehicleCancellationService.selectVehicleCancellationList(vehicleCancellation);
        return getDataTable(list);
    }

    /**
     * 导出机动车注销登记申请列表
     */

    /**
     * 获取机动车注销登记申请详细信息
     */
//    @RequiresPermissions("lvlian:vehicleCancellation:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(vehicleCancellationService.selectVehicleCancellationById(id));
    }


    @ApiOperation("根据车牌号查机动车注销登记申请")
    @GetMapping(value = "/getInfoByplateNo")
    public AjaxResult getInfoByplateNo( @ApiParam(value = "车牌号码", required = true) @RequestParam(value = "plateNo") String plateNo) {
        return success(vehicleCancellationService.getInfoByplateNo(plateNo));
    }




    /**
     * 修改机动车注销登记申请
     */
//    @RequiresPermissions("lvlian:vehicleCancellation:edit")
    @Log(title = "机动车注销登记申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleCancellation vehicleCancellation) {
        return toAjax(vehicleCancellationService.updateVehicleCancellation(vehicleCancellation));
    }

    /**
     * 删除机动车注销登记申请
     */
//    @RequiresPermissions("lvlian:vehicleCancellation:remove")
    @Log(title = "机动车注销登记申请", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(vehicleCancellationService.deleteVehicleCancellationByIds(ids));
    }
}
